<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;
session_start();
header('Content-Type:application/json; charset=utf-8');
header("Access-Control-Allow-Origin: *");//允许跨域请求
class Index extends Controller{

    public function index()
    {
       if($_POST['role'] == 1){
        $cid=$_POST['session_cid'];
            //查询考试记录表最后一条记录,如果是未补全的记录就补全
            $wei=Db::query("select * from tp_examination_records order by rid desc LIMIT 1 ");
            if($wei[0]['etime'] == '' && $wei[0]['cid'] == $cid){
              $new=Db::query("update tp_examination_records set etime = '".$wei[0]['stime']."',ltime=0,score=0 where etime = ''");
            }
           $message = Db::name('broker')->where('cid',$cid)->find();
           $info_1['name']=$message['name'];
           $info_1['exam']=$message['exam'];
           $info_1['registry']=$message['registry'];
           $info_1['role']=$_POST['role'];
           return json_encode($info_1,JSON_UNESCAPED_UNICODE);
       }
    }
}
